package com.zmn.oms.common.constant;

import com.zmn.common.dictionary.DictModel;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 类描述：渠道订单线索常量类
 *
 * @author lhl
 * @date 2021/01/08 17:22
 */
public final class OrderClueConsts {

    /* 订单线索状态常量 */
    public static final int CLUE_STATE_PENDING = 0;         // 待处理（未执行录单逻辑）
    public static final int CLUE_STATE_NON_DETAIL = 1;      // 无详情（已录单成功）
    public static final int CLUE_STATE_DETAIL_PENDING = 2;  // 详情待处理（录单失败，已记录线索详情）
    public static final int CLUE_STATE_DETAIL_DONE = 3;     // 详情已处理（录单失败过，线索已处理）

    /* 订单线索详情的处理状态常量 */
    public static final int DETAIL_STATE_PENDING = 0;       // 待处理
    public static final int DETAIL_STATE_IGNORED = 1;       // 已舍弃
    public static final int DETAIL_STATE_ORDER_APPLIED = 2; // 生成订单-处理中
    public static final int DETAIL_STATE_ORDERED = 3;       // 已生成订单



    public static String getOrderClueDetailStateName(Integer state) {
        switch (Optional.ofNullable(state).orElse(-1)) {
            case DETAIL_STATE_PENDING:
                return "待处理";
            case DETAIL_STATE_IGNORED:
                return "已舍弃";
            case DETAIL_STATE_ORDER_APPLIED:
                return "生成订单-处理中";
            case DETAIL_STATE_ORDERED:
                return "已成单";
            default:
                return "未知";
        }
    }

    /**
     * 获取线索单状态列表
     * @return
     */
    public static List<DictModel> getOrderClueDetailStateList() {
        List<DictModel> items = new ArrayList<>(3);
        items.add(new DictModel(DETAIL_STATE_PENDING, "待处理"));
        items.add(new DictModel(DETAIL_STATE_IGNORED, "已舍弃"));
        items.add(new DictModel(DETAIL_STATE_ORDERED, "已成单"));
        return items;
    }


    /**
     * 私有构造器，禁止实例化
     */
    private OrderClueConsts() {}
}
